package cn.jichangxiu.ucenter.controller;

import cn.jichangxiu.common.ucenter.entity.Role;
import cn.jichangxiu.common.web.model.response.QueryResult;
import cn.jichangxiu.common.web.model.response.R;
import cn.jichangxiu.common.web.model.response.ResponseCode;
import cn.jichangxiu.ucenter.service.inte.RoleService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiResponse;
import io.swagger.annotations.ApiResponses;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@Api(tags = "角色相关接口")
@RequestMapping("/api")
public class RoleController {

    @Autowired
    private RoleService roleService;

    @ApiOperation(value = "getRolesByUserId")
    @ApiResponses(value = {@ApiResponse(code = 801 , message = "查询成功！") , @ApiResponse(code = 901 , message = "查询失败！")})
    @GetMapping("/getRolesByUserId/{userId}")
    public R getRolesByUserId(@PathVariable("userId") String userId){
        List<Role> roles = roleService.getRolesByUserId(userId);
        return new R(ResponseCode.QUERY_SUCCESS , new QueryResult(roles));
    }

}
